{% extends 'index.html' %}

{% block head-js %}
    <script src="/static/plugin/ckeditor/ckeditor.js"></script>
{% endblock %}

{% block page-container %}
    <div class="new_article">
        {% if new_article_obj %}
            <h3>文章《{{ new_article_obj.title }}》已发布，<a href="{% url 'article_detail' new_article_obj.id %}">点我查看</a> </h3>
        {% else %}
            <form method="post" action="{%  url 'new_article' %}" enctype="multipart/form-data">{% csrf_token %}
            <input name="title" type="text" class="form-control" placeholder="文章标题" />
{#            {{ catagory_list }}#}
            <select name="categroy_id" class="form-control">
                {% for category in catagory_list %}
                    <option value="{{ category.id }}">{{ category.name }}</option>
                {% endfor %}
            </select>
            <input name="summary" type="text" class="form-control" placeholder="文章简介" />
            <input name="head_img" type="file" />必选文章标题图片
{#            CKEditor textarea#}
            <textarea id="ck-editor" name="content" class="form-control" rows="3"></textarea>
            <br>
            <button type="submit" class="btn btn-success pull-right" >发帖</button>
        </form>
        {% endif %}
    </div>
{% endblock %}

{% block bottom-js %}
    <script type="text/javascript">
        CKEDITOR.replace('ck-editor');
{#        还也可以自定义配置#}
{#        CKEDITOR.editorConfig = function(config){#}
{#            config.uiColor = '#F7B42C';#}
{#            config.height = 300 ;#}
{#        };#}
    </script>
{% endblock %}